/**********************************************************************//**
 * @file bmp.h
 * @brief function summary
 *
 * Development Div. : PI&S SSE CAM3
 * Author : Yoichiro SATO\n
 * Copyright 2011 Sony Corporation. \n
 * ================================================================== */
/**********************************************************************/
#ifndef _BMP_H_
#define _BMP_H_

/* --- include files ------------------------------------------------ */
/* --- macro definitions -------------------------------------------- */
#define ICEIL(dividend, divisor) (((dividend) + ((divisor) - 1)) / (divisor))

/* --- structure/class definitions ---------------------------------- */
typedef struct tagBITMAPFILEHEADER {
	unsigned short bfType;
	unsigned int  bfSize;
	unsigned short bfReserved1;
	unsigned short bfReserved2;
	unsigned int  bfOffBits;
} BITMAPFILEHEADER;


typedef struct tagBITMAPFILEHEADERPACK {
	unsigned char packed[14];
} BITMAPFILEHEADERPACK;


typedef struct tagBITMAPINFOHEADER{
    unsigned int  biSize;
    int           biWidth;
    int           biHeight;
    unsigned short biPlanes;
    unsigned short biBitCount;
    unsigned int  biCompression;
    unsigned int  biSizeImage;
    int           biXPixPerMeter;
    int           biYPixPerMeter;
    unsigned int  biClrUsed;
    unsigned int  biClrImporant;
} BITMAPINFOHEADER;

/* --- function prototypes ------------------------------------------ */
extern int get_bmp_size(char *p_file_name, int *width, int *height);
extern int get_bmp_rgb_data(char *p_file_name, int rgb_size, unsigned char *p_rgb);
extern void rgb_to_yuv444(int bitmap_width, int width, int height, unsigned char* bitmap_data, unsigned char* buf_yuv);
extern void rgb_to_yuv422(int line_width, int pixel_width, int width, int height, unsigned char* bitmap_data, unsigned char* buf_yuv);
extern void rgb_to_y(int bitmap_width, int width, int height, unsigned char* bitmap_data, unsigned char* buf_y);
extern void rgb_to_lab(int bitmap_width, int width, int height, unsigned char* bitmap_data, int* buf_lab);
extern void resize_rgb(int line_width, int width, int height, int new_width, int new_height,
                       unsigned char* bitmap_data, unsigned char* p_resized);
extern void resize_yuv422(int line_width, int width, int height, int new_width, int new_height,
                          unsigned char* p_yuv_data, unsigned char* p_resized);
extern void resize_element(int width, int height, int new_width, int new_height,
                           unsigned char* bitmap_data, unsigned char* p_resized);
extern void dump_out_bmp_rgb(int nWidth, int nHeight, unsigned char *p_rgb, const char* pFileName);
extern void rotate_r90_yuv422(int width, int height, unsigned char* p_yuv_data, unsigned char* p_rotated_data);
extern void rotate_l90_yuv422(int width, int height, unsigned char* p_yuv_data, unsigned char* p_rotated_data);
extern void hsv_to_rgb(unsigned char hsx, unsigned char hsy, unsigned char z,
                       unsigned char *r, unsigned char *g, unsigned char *b);
extern void get_ppm_size(char *p_ppm_filename, int *width, int *height);
extern void ppm_to_rgb(char *p_ppm_filename, unsigned char *p_rgb);

extern void yuv422_to_rgb(int line_width, int width, int height, unsigned char* buf_yuv, unsigned char* bitmap_data);
extern void yuv422_to_rgba(int line_width, int width, int height, unsigned char* buf_yuv, unsigned char* bitmap_data);

/* --- static values ------------------------------------------------ */
/* --- auto values -------------------------------------------------- */

#endif //_BMP_H_ // #ifndef
